//
//  HJSellOderBottom.m
//  Sneakers
//
//  Created by 胡光健 on 2017/9/22.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HJSellOderBottom.h"
#import "HJHomeModel.h"

@interface HJSellOderBottom()

@end
@implementation HJSellOderBottom


-(instancetype)init {
    if (self = [super init]) {
        self = [[NSBundle mainBundle]loadNibNamed:@"HJSellOderBottom" owner:nil options:nil].firstObject;
        self.is_sell = NO;
    }
    return self;
}

- (IBAction)sellBtn:(UIButton *)sender {
    if (!self.is_sell) {
        [mNotificationCenter postNotificationName:@"loadOrderAddNotification" object:nil];
        self.is_sell = YES;
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            self.is_sell = NO;
        });
    }
}
- (IBAction)days:(UIButton *)sender {
     [self animationLineWithBtn:sender];
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    if (sender.tag==5) {
        dic[@"days"] = @"15";
    }else if (sender.tag==4) {
        dic[@"days"] = @"7";
    }else {
        dic[@"days"] = @"3";
    }
    [mNotificationCenter postNotificationName:@"loadOrderNot" object:nil userInfo:dic];
}
// 滑动线条
-(void)animationLineWithBtn:(UIButton *)btn {
    for (int i = 3; i<=5; i ++) {
        UIView *view = [self viewWithTag:i];
        view.alpha = 0.5;
    }
    btn.alpha = 1;
    [UIView animateWithDuration:0.1 animations:^{
        _line.centerX = btn.centerX;
    }];
}
-(void)setModel:(HJOderModel *)model {
    _model = model;
    self.serviceFee.text = [NSString stringWithFormat:@"￥%@",model.serves_fee];
    if (self.tag==101) {
        self.timeH.constant = 0.001;
        self.timeView.hidden = YES;
    }
    self.instructions.text = model.trade_detail;
    self.instructionH.constant = model.trade_H;
    self.instructionAllH.constant = model.trade_H + 91;
    if (self.tag == 101) {
        self.earnings.text = [NSString stringWithFormat:@"￥%.2f",model.want_buy.shoes_cost.integerValue - (model.want_buy.shoes_cost.integerValue * 0.05) - model.serves_fee.integerValue];
    }
}
@end
